﻿
namespace Leetcode.N0883;

public class Solution
{
    public int ProjectionArea(int[][] grid)
    {
        int area = 0;
        for (int i = 0; i < grid.Length; i++)
        {
            int xz = 0;
            int yz = 0;
            for (int j = 0; j < grid.Length; j++)
            {
                area += grid[i][j] == 0 ? 0 : 1;
                xz = Math.Max(xz, grid[i][j]);
                yz = Math.Max(yz, grid[j][i]);
            }
            area += xz + yz;

        }
        return area;
    }
}
